home *** CD-ROM | disk | FTP | other *** search
/ Aminet 30 / Aminet 30 (1999)(Schatztruhe)[!][Apr 1999].iso / Aminet / util / pack / xpk_Source.lha / xpk_Source / test / testNILPack.c < prev    next >
C/C++ Source or Header  |  1998-11-09  |  2KB  |  110 lines

  1. #define NAME        "testNILPack"
  2. #define DISTRIBUTION    "(Freeware) "
  3. #define REVISION    "1"
  4.  
  5. /* Programmheader
  6.  
  7.     Name:        testNILPack
  8.     Author:        SDI
  9.     Distribution:    Freeware
  10.     Description:    tests Xpk with NIL argument function
  11.     Compileropts:    -
  12.     Linkeropts:    -l xpkmaster amiga
  13.  
  14.  1.0   01.04.97 : first version
  15.  1.1   28.11.97 : moved chunk-hook into include file
  16. */
  17.  
  18. /* Example to show, that xpkmaster may also pack and unpack into NIL:
  19. useful for speed test only. */
  20.  
  21. #include <proto/dos.h>
  22. #include <proto/xpkmaster.h>
  23. #include <proto/exec.h>
  24. #include "SDI_defines.h"
  25. #include "chunkfunc.c"
  26.  
  27. struct Library *XpkBase;
  28.  
  29. void main(int argc, char **argv)
  30. {
  31.   STRPTR obuf = 0;
  32.   ULONG fh, err, obuflen = 0, olen = 0;
  33.  
  34.   if(argc != 2)
  35.   {
  36.     VPrintf("Filename needed\n", 0);
  37.     exit(0);
  38.   }
  39.  
  40.   if(!(XpkBase = OpenLibrary("xpkmaster.library", 4)))
  41.     exit(10);
  42.  
  43.   if(!(fh = Open("NIL:", MODE_NEWFILE)))
  44.   {
  45.     VPrintf("Could not open fh\n", 0);
  46.     CloseLibrary(XpkBase);
  47.     exit(10);
  48.   }
  49.  
  50.   VPrintf("Testing FH Pack access\n", 0);
  51.  
  52.   if((err = XpkPackTags(
  53.     XPK_InName,    argv[1],
  54.     XPK_OutFH,    fh,
  55.     XPK_ChunkHook,    &chunkhook,
  56.     XPK_PackMethod,    "NUKE",
  57.     TAG_DONE)))
  58.     XpkPrintFault(err, "FH Pack try");
  59.  
  60.   VPrintf("Testing Name Pack access\n", 0);
  61.  
  62.   if((err = XpkPackTags(
  63.     XPK_InName,    argv[1],
  64.     XPK_OutName,    "NIL:",
  65.     XPK_ChunkHook,    &chunkhook,
  66.     XPK_PackMethod,    "NUKE",
  67.     TAG_DONE)))
  68.     XpkPrintFault(err, "Name Pack try");
  69.  
  70.   VPrintf("Producing packed file\n", 0);
  71.  
  72.   if((err = XpkPackTags(
  73.     XPK_InName,        argv[1],
  74.     XPK_PackMethod,        "NUKE",
  75.     XPK_GetOutBuf,        &obuf,
  76.     XPK_GetOutBufLen,     &obuflen,
  77.     XPK_GetOutLen,         &olen,
  78.     XPK_ChunkHook,        &chunkhook,
  79.     TAG_DONE)))
  80.     XpkPrintFault(err, "Normal Pack try");
  81.  
  82.   VPrintf("Testing FH Unpack access\n", 0);
  83.  
  84.   if((err = XpkUnpackTags(
  85.     XPK_InBuf,    obuf,
  86.     XPK_InLen,    olen,
  87.     XPK_OutFH,    fh,
  88.     XPK_ChunkHook,    &chunkhook,
  89.     TAG_DONE)))
  90.     XpkPrintFault(err, "FH Unpack try");
  91.  
  92.   VPrintf("Testing direct Unpack access\n", 0);
  93.  
  94.   if((err = XpkUnpackTags(
  95.     XPK_InBuf,    obuf,
  96.     XPK_InLen,    olen,
  97.     XPK_OutName,    "NIL:",
  98.     XPK_ChunkHook,    &chunkhook,
  99.     TAG_DONE)))
  100.     XpkPrintFault(err, "Name Unpack try");
  101.  
  102.   if(obuf)
  103.     FreeMem(obuf, obuflen);
  104.  
  105.   if(!Close(fh))
  106.     VPrintf("Could not close fh\n", 0);
  107.   CloseLibrary(XpkBase);
  108. }
  109.  
  110.